// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
//引入库
import Vue from 'vue'
import VRouter from 'vue-router'
import Vuex from 'vuex'
import VResource from 'vue-resource'
//引入自己定义的组件
/*
import Apple from './components/apple'
import  Banana from './components/banana'
import  RedApple from './components/RedApple.vue'
import  GreenApple from './components/GreenApple.vue'
*/
import  Layout from './components/layout.vue'


import IndexPage from './pages/index.vue'
import DatailPage from './pages/detail.vue'
import DetailAnaPage from './pages/detail/analysis.vue'
import DetailCouPage from './pages/detail/count.vue'
import DetailForPage from './pages/detail/forecast.vue'
import DetailPubPage from './pages/detail/publish.vue'

import OrderListPage from './pages/orderList.vue'

Vue.config.productionTip = false;



Vue.use(VRouter);
Vue.use(Vuex);

/*开启$http功能*/
Vue.use(VResource);



/*let store = new Vuex.Store({
  state:{
    totalPrice:0
  },
  //用来获取状态集里面的数据
  getters:{
    getTotal(state){
      return state.totalPrice;
    }
  },
  mutations:{
    //mutations中是同步的去操作数据

    increment(state,price){
      state.totalPrice += price;
    },
    decrement(state,price){
      state.totalPrice -= price;
    }
  },
  //actions只能去调用mutations，不能去更改state的这样的一个数据流
  actions: {
    //actions中可以去进行一些异步的操作，然后再去触发mutations

    //这里传入的参数context就是$store
    increase(context,price) {
      context.commit('increment',price);
    },
    decrease(context,price){
      context.commit('decrement',price);
    }

  }
});


//定义路由实例
let router = new VRouter({
  //把节点设置为history
  mode:'history',
  routes:[
    {
      /!*在路径后面加入传入到当前页面的参数*!/
      path:'/apple',
      component:Apple,
      children:[
        {
          //不是从根节点开始
          path:'red',
          component: RedApple
        },
        {
          path:'green',
          component: GreenApple
        }
      ]
    },
    {
      path:'/banana',
      component:Banana
    }
  ]
});*/


let router= new VRouter({
  mode:'history',
  routes:[
    {
      path:'/',
      component:IndexPage
    },
    {
      path:'/orderList',
      component:OrderListPage
    },
    {
      path:'/detail',
      component:DatailPage,
      redirect: '/detail/analysis',
      children:[
        {
          path:'analysis',
          component:DetailAnaPage
        },
        {
          path:'count',
          component:DetailCouPage
        },
        {
          path:'forecast',
          component:DetailForPage
        },
        {
          path:'publish',
          component:DetailPubPage
        }
      ]
    }
  ]
})

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router:router,
  template: '<Layout/>',
  components: { Layout }
})
